package com.verbetia.musictrends.service;

import java.sql.SQLException;
import java.util.ArrayList;

import com.verbetia.musictrends.persistence.hsqldb.MusicEntity;
import com.verbetia.musictrends.persistence.hsqldb.MusicsPersMngr;
import com.verbetia.musictrends.persistence.hsqldb.UsersPersMngr;
import com.verbetia.musictrends.persistence.hsqldb.Utils;

public class RssGenerator {
	
	public RssGenerator()
	{
		
	}
	
	
	public ArrayList<MusicEntity> generateFeed(String userid)
	{
		ArrayList<MusicEntity> r = null;
		MusicsPersMngr music = new MusicsPersMngr();
		
		
        try  			
        {
		 r = 	Utils.rs2MusicEntity(
				 			music.selectQuery(userid, 0)
				);
        } catch (SQLException sqle)
        {
        	System.out.println(sqle);
        }
        
        
        return r;
		
	}
	
	
	public int authenticate(String username, String password)
	{
		UsersPersMngr users = new UsersPersMngr();
		int userid=UsersPersMngr.USER_NOT_EXSIST;
		
		try {
			userid = users.authenticateUser(username, password);
		} catch (SQLException e)
		{
			System.out.println(e);			
		}
		
		return userid;
		
	}

}
